<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <table border="1" cellspacing='0'>
        <tr>
            <th>序号</th>
            <th>用户名</th>
            <th>密码</th>
            <th>删除</th>
            <th>修改</th>
        </tr>
        <%  for(var i = 0 ; i < list.length ; i++) { %>
        </tr>
        <td><%= i+1 %></td>
        <td><%= list[i].username %></td>
        <td><%= list[i].password %></td>
        <td><a href="javascript:;" data-id="<%= list[i].id %>" class="ob">删除</a></td>
        <td><a href="javascript:;" data-id="<%= list[i].id %>" class="obtn">修改</a></td>
        </tr>
        <% } %>

    </table>
    <script>
        var oBtn = document.querySelectorAll('.ob');
        var obtn = document.querySelectorAll('.obtn');
        for (var i = 0; i < oBtn.length; i++) {
            oBtn[i].onclick = function () {
                id = this.getAttribute('data-id');
                location.href = '/deluser?id=' + id;
            }
        };
        for (var i = 0; i < obtn.length; i++) {
            obtn[i].onclick = function () {
              var id = this.getAttribute('data-id');
                location.href = '/gai?id=' + id;
            }
        }
    </script>
</body>

</html>